﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace Helpers
{
    public class CollectionHelper
    {
        public static bool IsNullOrEmpty(IEnumerable collection)
        {
            if(collection == null)
                return true;
            
            IEnumerator enumerator = collection.GetEnumerator();
            enumerator.Reset();
            return !enumerator.MoveNext();
        }

        public static bool IsNullOrEmpty<T>(IEnumerable<T> collection)
        {
            return collection == null || collection.Count() == 0;
        }

        public static bool IsNullOrEmpty<T>(T[] collection)
        {
            return collection == null || collection.Length == 0;
        }
    }
}
